package com.ruoyi.common.utils;

import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Classname RegularUtils
 * @Author: sunluquan
 * @Date: 2022/5/29 10:58
 * @Description TODO
 * 正则表达式工具类
 */
public class RegularUtils {
    /** 文件分割符统一表达式 **/
    public final static String FILE_SEPARATOR_PATTERN = "(\\\\|\\/)+";

    /**
     * 返回统一分隔符的文件路径
     * @param path
     * @return
     */
    public static String unifiedSeparator(String path){
        if(StringUtils.isNotEmpty(path)){
            return path.replaceAll(FILE_SEPARATOR_PATTERN,  Matcher.quoteReplacement(File.separator));
        }
        return path;
    }
    public static void main(String[] args) {

        String name = "13800138000" ;
        String regex ="(\\d{3})\\d{4}(\\d{4})" ;
        String result = name.replaceAll(regex, "$1****$2");
        System.out.println(result);
        String path = "D:/工作文档\\\\\\\\//生产线项目文档\\成都-辰飞智匠-生产线项目\\技术协议";
        System.out.println(path);
        String s = path.replaceAll("(\\\\|\\/)+",  Matcher.quoteReplacement(File.separator));

        System.out.println(s);
    }
}
